/**
 * author:Administrator
 * date:2013-5-21
 */
package com.roc.web.action.setting;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

/**
 * @author Feng haitao
 *
 */
public class HRTSettingSearchCondition extends BaseSearchCondition {

	private String merNo;
	private String realName;
	private String settFlag;
	private String minDate;
	private String maxDate;
	private String orgCode;
	private String frozenFlag;
	private String setDate;
	private String accountNo;
	private String accountName;
	private String loadFlag;
	private String modelFlag;
	private String excelFlag;

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getOrderPartOfHQL()
	 */
	@Override
	protected String getOrderPartOfHQL() {
		// TODO Auto-generated method stub

		return " order by t.orderno ";
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getRowCountHQL()
	 */
	@Override
	protected String getRowCountHQL() {
		StringBuffer sb = new StringBuffer();
		sb.append("select count(*) from t_transjnls_settleload t where 1=1 ");
		
		return sb.toString();
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getSearchHQL()
	 */
	@Override
	protected String getSearchHQL() {
		// TODO Auto-generated method stub

		return " select t.orderno,t.merchantno,t.merchantname,t.settledate,t.freezeflag,t.totalamt,t.totalnum,t.merchantfee,t.merchantsettleamt,t.settleflag,t.batchno,t.setdate,t.bankdeposit,t.accountname,t.accountno from t_transjnls_settleload t where 1=1 ";
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getWhereHQLFieldBeanList()
	 */
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();

		if (Constance.isNotEmpty(merNo)) {
			filedBeanList.add(new WhereHQLFieldBean("t.merchantno", merNo
					.trim().trim(), "=", false));
		}
		if (Constance.isNotEmpty(settFlag)) {
			filedBeanList.add(new WhereHQLFieldBean("t.settleflag", settFlag
					.trim(), "=", false));
		}

		if (Constance.isNotEmpty(realName)) {
			filedBeanList.add(new WhereHQLFieldBean("t.merchantname", realName
					.trim(), "LIKE", false, "ALL"));
		}
		if (Constance.isNotEmpty(accountName)) {
			filedBeanList.add(new WhereHQLFieldBean("t.accountname", accountName.trim(),
					"LIKE", false, "ALL"));
		}
		if (Constance.isNotEmpty(accountNo)) {
			filedBeanList.add(new WhereHQLFieldBean("t.accountno", accountNo.trim(), "=", false));
		}
		if (Constance.isNotEmpty(orgCode)) {
			filedBeanList.add(new WhereHQLFieldBean("t.orgno", orgCode.trim()
					.trim(), "=", false));
		}

		if (Constance.isNotEmpty(minDate) && Constance.isNotEmpty(maxDate)) {
			//Date startDate = Constance.formateDate(minDate);
			//Date endDate = Constance.formateDate(maxDate);
			String startDate = minDate.replace("-", "");
			String endDate = maxDate.replace("-", "");
			filedBeanList.add(new WhereHQLFieldBean("t.settledate", startDate,
					">=", false));
			filedBeanList.add(new WhereHQLFieldBean("t.settledate", endDate,
					"<=", false));
		}
		if (Constance.isNotEmpty(setDate)) {
			filedBeanList.add(new WhereHQLFieldBean("t.setdate", setDate.trim()
					.trim(), "=", false));
		}
		if (Constance.isNotEmpty(frozenFlag)) {
			filedBeanList.add(new WhereHQLFieldBean("t.FREEZEFLAG", frozenFlag.trim()
					.trim(), "=", false));
		}
		if (Constance.isNotEmpty(loadFlag)) {
			filedBeanList.add(new WhereHQLFieldBean("t.loadFlag", loadFlag.trim()
					.trim(), "=", false));
		}
		return filedBeanList;
	}

	public String getFrozenFlag() {
		return frozenFlag;
	}

	public void setFrozenFlag(String frozenFlag) {
		this.frozenFlag = frozenFlag;
	}

	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}

	/**
	 * @return the realName
	 */
	public String getRealName() {
		return realName;
	}

	/**
	 * @param realName the realName to set
	 */
	public void setRealName(String realName) {
		this.realName = realName;
	}

	/**
	 * @return the minDate
	 */
	public String getMinDate() {
		return minDate;
	}

	/**
	 * @param minDate the minDate to set
	 */
	public void setMinDate(String minDate) {
		this.minDate = minDate;
	}

	/**
	 * @return the maxDate
	 */
	public String getMaxDate() {
		return maxDate;
	}

	/**
	 * @param maxDate the maxDate to set
	 */
	public void setMaxDate(String maxDate) {
		this.maxDate = maxDate;
	}

	public String getMerNo() {
		return merNo;
	}

	public void setMerNo(String merNo) {
		this.merNo = merNo;
	}

	public String getSettFlag() {
		return settFlag;
	}

	public void setSettFlag(String settFlag) {
		this.settFlag = settFlag;
	}

	public String getSetDate() {
		return setDate;
	}

	public void setSetDate(String setDate) {
		this.setDate = setDate;
	}

	public String getAccountNo() {
		return accountNo;
	}

	public void setAccountNo(String accountNo) {
		this.accountNo = accountNo;
	}

	public String getAccountName() {
		return accountName;
	}

	public void setAccountName(String accountName) {
		this.accountName = accountName;
	}

	public String getLoadFlag() {
		return loadFlag;
	}

	public void setLoadFlag(String loadFlag) {
		this.loadFlag = loadFlag;
	}

	public String getModelFlag() {
		return modelFlag;
	}

	public void setModelFlag(String modelFlag) {
		this.modelFlag = modelFlag;
	}

	public String getExcelFlag() {
		return excelFlag;
	}

	public void setExcelFlag(String excelFlag) {
		this.excelFlag = excelFlag;
	}

	public static void main(String[] args) {
		HRTSettingSearchCondition s = new HRTSettingSearchCondition();
		Object[] ids = new Object[] { "dxpeng", "lisi", "wangwu" };
		//s.setSuperiorId(1l);

		try {

			System.out.println(s.getFullSearchHQL(null));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
